const Koa = require('koa')
const app = new Koa()

const middleware1 = function async(ctx, next) {
	console.log('this is a md-1');
	console.log(ctx.request.path);
	next();
	console.log('this is md-1 ending')
}
const middleware2 = function async(ctx, next) {
	console.log('this is a md-2');
	console.log(ctx.request.path);
	// next();
	// console.log('this is md-2 ending')
}
const middleware3 = function async(ctx, next) {
	console.log('this is a md-3');
	console.log(ctx.request.path);
	next();
	console.log('this is md-3 ending')
}

// app.use按顺序执行
app.use(middleware1)
app.use(middleware2)
app.use(middleware3)

/**
 * [result]
 * this is a md-1
 * this is a md-2
 * this is md-1 ending
 */

app.listen(3001)